package com.team11.server.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team11.server.mapper.CInformationMapper;
import com.team11.server.pojo.CInformation;
import com.team11.server.service.ICInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author pjc
 * @since 2021-06-15
 */
@Service
public class CInformationServiceImpl extends ServiceImpl<CInformationMapper, CInformation> implements ICInformationService {

    @Resource
    private CInformationMapper cInformationMapper;

    /**
     * 获取所有专业名称
     * @return 专业
     */
    @Override
    public Object getMajor() {
        List<CInformation> items = cInformationMapper.selectList(null);
        List<String> list = items.stream().map(CInformation::getCMajor).collect(Collectors.toList());
        return new ArrayList<>(new TreeSet<>(list));
    }

    /**
     * 获取年级
     *
     * @return Object
     */
    @Override
    public Object getGrade() {
        List<CInformation> items = cInformationMapper.selectList(null);
        List<String> list1 = items.stream().map(CInformation::getCGrade).collect(Collectors.toList());
        return new ArrayList<>(new TreeSet<>(list1));
    }

    /**
     * 获取班级
     *
     * @return Object
     */
    @Override
    public Object getCClass() {
        List<CInformation> items = cInformationMapper.selectList(null);
        List<String> list = items.stream().map(CInformation::getCClass).collect(Collectors.toList());
        return new ArrayList<>(new TreeSet<>(list));
    }

    /**
     * 获取学院名称
     * @return Object
     */
    @Override
    public Object getCDepartment() {
        List<CInformation> items = cInformationMapper.selectList(null);
        List<String> list = items.stream().map(CInformation::getCDepartment).collect(Collectors.toList());
        return new ArrayList<>(new TreeSet<>(list));
    }
}
